/*
 * author zby
 * 首页初始化数据
 */

(function (document, window, $, Utils) {
    'use strict';
    var areaId, udrId, id;
    var vm = {}
    $(function () {
        var fns = {
            search: function (me) {
                Utils.getSimpleJson({
                    url: "/manager/contact/page",
                    params: Utils.getSearchParams(me),
                    fn: function (data) {
                        vm.contacts = data;
                    }
                })
            },
            del: function (cid) {
                Utils.delete({
                    url: "/core/contacts",
                    id: cid
                })
            },
            look: function (cid) {
                for (var i = 0; i < $("#content").length; i++) {
                    $("#content")[i].innerHTML = '';
                }
                $("#contactModal").modal();
                Utils.getSimpleJson({
                    url: "/manager/contact/" + cid,
                    fn: function (data) {
                        $("#content").append(data.content);
                    }
                })

            }
        };
        window.fns = fns;
        init();
    });

    //入口方法
    function init() {
        vm = new Vue({
            el: '#tableInfo',
            data: {
                enums: {},
                contacts: {}
            },
        })
        Utils.getSimpleJson({
            url: "/core/enum/list",
            noAsync: false,
            params: {
                path: "ContactTypeEnum,BooleanEnum,ReplyWayEnum",
            },
            fn: function (data) {
                vm.enums = data;
            }
        })
        fns.search();

    }


})(document, window, jQuery, Utils);